package fr.cephb.servlet;


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Default abstract implementation of a javax.servlet.Filter
 * @author lindenb
 *
 */
public abstract class AbstractFilter implements Filter
	{
	private FilterConfig filterConfig;

	public AbstractFilter()
		{
		}
	
	@Override
	public void init(FilterConfig filterConfig) throws ServletException
		{
		this.filterConfig=filterConfig;
		}
	/**
	 * return the FilterConfig for this filter
	 * @return the FilterConfig for this filter
	 */
	public FilterConfig getFilterConfig()
		{
		return this.filterConfig;
		}
	
	@Override
	public void destroy()
		{
		this.filterConfig=null;
		}
	
	@Override
	public String toString() {
		return getFilterConfig()==null?"undefined filter":getFilterConfig().getFilterName();
		}

	@Override
	public abstract void doFilter(
			ServletRequest req,
			ServletResponse res,
			FilterChain chain) throws IOException, ServletException;
}
